package com.samoiloff.ui.progress {
	import flash.display.MovieClip;

	/**
	 * @author Samoiloff
	 */
	public class ProgressController {
		
		private var _mc		: MovieClip;		
		private var _hitMc	: MovieClip;
		private var _maxWidth: int;

		private var _progress: Number;
		
		public function ProgressController(mc:MovieClip) {
			_mc = mc;
			_hitMc = _mc.hitMc;
			_maxWidth = _hitMc.width;
			
			progress = 0;
		}
		
		public function destroy():void {
			_mc = null;
			_hitMc = null;
		}

		public function get progress(): Number {
			return _progress;
		}
		
		public function set progress(progress: Number): void {
			_progress = progress;
			if (_progress < 0) { _progress = 0; }
			if (_progress > 1) { _progress = 1; }
			_hitMc.width = _progress * _maxWidth;
		}

		public function get hitMc(): MovieClip {
			return _hitMc;
		}
		
		public function get mc(): MovieClip {
			return _mc;
		}
	}
}
